import { useMemo } from "react";
import { useProjectIdInUrl } from "../billboard/utils";
import { useUrlQueryParam } from "../../hooks/useUrlQueryParam";

export const useEpicsSearchParams = () => {
  const projectId = useProjectIdInUrl();
  return useMemo(() => ({ projectId }), [projectId]);
};

export const useEpicDrawer = () => {
  const [{ epicCreation }, setEpicCreation] = useUrlQueryParam([
    "epicCreation",
  ]);
  const onClose = () => setEpicCreation({ epicCreation: "" });
  const onOpen = () => setEpicCreation({ epicCreation: true });
  return {
    visible: epicCreation === "true",
    onClose,
    onOpen,
  };
};

export const useEpicQueryKey = () => ["epics", useEpicsSearchParams()];
